package FulbitoFacil.Servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import FulbitoFacil.excepcion.DAOExcepcion;
import FulbitoFacil.modelo.Horario;
import FulbitoFacil.modelo.Local;
import FulbitoFacil.negocio.*;

@WebServlet("/InsertarCancha")
public class InsertarCancha extends javax.servlet.http.HttpServlet implements
		javax.servlet.Servlet {
	static final long serialVersionUID = 1L;

	public InsertarCancha() {
		super();

	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		Local local = request.getParameter("sltLocal");
		String nombre = request.getParameter("txtNombre");
		String caracteristica = request.getParameter("txtDescripcion");
		String promocion = request.getParameter("txtPromocion");
		String foto = request.getParameter("txtFoto");
		Horario horario = request.getParameter("sltHorario");

		GestionCancha gc = new GestionCancha();
		try {
			gc.insertarCancha(local, nombre, caracteristica, promocion, foto,
					horario);

		} catch (DAOExcepcion e) {
			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
			rd.forward(request, response);
		}

	}

}
